var _ = require("lodash");
// _.takeWhile(array, [predicate=_.identity])
// 从array数组的起始元素开始提取元素，，直到 predicate 返回假值
var users = [
  { user: "barney", active: false },
  { user: "fred", active: false },
  { user: "pebbles", active: true },
];

let a = _.takeWhile(users, function (o) {
  return !o.active;
});
// console.log(a);

let b = _.takeWhile(users, { user: "barney", active: false });
// console.log(b);

let c = _.takeWhile(users, ["active", false]);
// console.log(c);

// _.takeRightWhile(array, [predicate=_.identity])
// 从array数组的最后一个元素开始提取元素，直到 predicate 返回假值
let d = _.takeRightWhile(users, function (o) {
  return o.active;
});
// console.log(d);

let e = _.takeRightWhile(users, { user: "pebbles", active: true });
console.log(e);
